package com.leapp.sk.ui.adapter

import android.content.Context
import android.content.Intent
import android.view.View
import com.example.mvp.adapter.BaseLibMultipleViewAdapter
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.delegate.BaseAdapterDelegate
import com.leapp.sk.R
import com.leapp.sk.bean.ParentingTaskEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.ui.activity.task.TaskCorrectActivity
import com.leapp.sk.viewdelegate.adapter.task.TaskCompleteDegreeAdapterDelegate

/**
 * 作业完成适配器
 * @author  chaohaipeng  on 2018/8/10.
 */
class TaskCompleteDegreeAdapter  (context: Context, mlist: List<ParentingTaskEntity>) : BaseLibMultipleViewAdapter<ParentingTaskEntity>(context, mlist){
    /**
     * 数据
     */
    val mList = mlist
    /**
     * 上下文
     */
    val mContext = context


    override fun bindEvenListener(viewDelegate: BaseAdapterDelegate?, position: Int) {
        if(viewDelegate is TaskCompleteDegreeAdapterDelegate){
            viewDelegate?.setOnClickListener(View.OnClickListener {
                val intent=Intent(mContext,TaskCorrectActivity::class.java)
                mContext.startActivity(intent)
            }, R.id.tv_atcd_review)
        }


    }

    override fun notifyView(viewDelegate: BaseAdapterDelegate?, position: Int) {
    }

    override fun getDelegate(position: Int): BaseAdapterDelegate {
      return  TaskCompleteDegreeAdapterDelegate::class.java?.newInstance()
    }

    override fun getDataBinder(position: Int): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun getItemData(position: Int): Any {
        return mList.get(position)
    }
}